<template>
    <div class="breadcrumb">
        当前位置：
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item v-for="(item, i) in nav_list" :key="i">
                <a :href="item.url ? item.url : 'javascript:;'">{{item.title}}</a>
            </el-breadcrumb-item>
        </el-breadcrumb>
    </div>
</template>

<script lang="js">
import { defineComponent, reactive, toRefs, watch } from 'vue'
import { useStore } from 'vuex'
export default defineComponent({
    setup() {
        const store = useStore()
        let state = reactive({
            nav_list: []
        })
        state.nav_list = sessionStorage.nav ? JSON.parse(sessionStorage.nav) : ''
        
        watch(store.state, () => {
            state.nav_list = sessionStorage.nav ? JSON.parse(sessionStorage.nav) : ''
        })

        return {
            ...toRefs(state)
        }
    }
})
</script>

<style lang="scss" scoped>
.breadcrumb{
    display: flex;
    color: #999;
    line-height: 20px;
    font-size: 14px;
    margin-bottom: 15px;
}
</style>